﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace LybrixNursingCRMDesktop.FrameWork
{
    public class ValidationFunctions
    {
        public static bool IsNullEmpty(string input)
        {
            return string.IsNullOrWhiteSpace(input);
        }

        public static bool IsNumeric(string input)
        {
            int numeric = 0;
            return Int32.TryParse(input, out numeric);
        }

        public static bool IsDouble(string input)
        {
            double doub = 0;
            return Double.TryParse(input, out doub);
        }

        public static bool IsValidEmail(string input)
        {
            return Regex.IsMatch(input,
                                 @"^(?("")(""[^""]+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" +
                                 @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$");
        }

        public static bool IsValidPhone(string input)
        {
            return true;
        }

        //public static bool IsValidLibrarianLoginName(string loginName)
        //{
        //    LibCoreEntities _entities;
        //    IQueryable<librarian> librarians;
        //    _entities = Repository.Entities;
        //    librarians = _entities.librarians.Where(x => x.name == loginName).Distinct<librarian>();
        //    if (librarians.AsQueryable().Count() > 0)
        //        return false;
        //    else
        //        return true;
        //}
    }
}
